package s2elinshu;

import java.util.Scanner;

public class J10SungJuk {
	public static void main(String[] args) {
		String name, grd;
		int kor, eng, mat, tot;
		double avg;
		// 주의 : scanner 클래스를 이용해서 입력처리하고
		// sc.close()를 하게되면 다시 scanner생성불가!

		name = inputName(makeScanner());
		kor = inputKor(makeScanner());
		eng = inputEng(makeScanner());
		mat = inputMat(makeScanner());
		tot = getTot(kor, eng, mat);
		avg = getAvg(tot);
		grd = getGrd(avg);

		System.out.println(name);
		System.out.println(kor);
		System.out.println(eng);
		System.out.println(mat);
		System.out.println(tot);
		System.out.println(avg);
		System.out.println(grd);

	}// main 닫음

	private static int inputMat(Scanner sc) {
		int mat;
		System.out.println("수학점수를 입력하세요");
		mat = sc.nextInt();
		closeScanner(sc);
		return mat;
	}

	private static int inputEng(Scanner sc) {
		int eng;
		System.out.println("영어점수를 입력하세요");
		eng = sc.nextInt();
		return eng;
	}

	private static int inputKor(Scanner sc) {
		int kor;
		System.out.println("국어점수를 입력하세요");
		kor = sc.nextInt();
		return kor;
	}

	private static String inputName(Scanner sc) {
		String name;
		System.out.println("이름을 입력하세요");
		name = sc.next();
		return name;
	}

	// scanner 생성
	public static Scanner makeScanner() {
		Scanner sc = new Scanner(System.in);
		return sc;
	}

	// scanner 소멸
	public static void closeScanner(Scanner sc) {
		sc.close();
	}

	private static int getTot(int kor, int eng, int mat) {
		return (kor + eng + mat);
	}

	private static double getAvg(int tot) {
		return ((double) tot / 3);
	}

	private static String getGrd(double avg) {
		String grd;
		switch ((int) avg / 10) {
		case 10:
		case 9:
			grd = "수";
			break;
		case 8:
			grd = "우";
			break;
		case 7:
			grd = "미";
			break;
		case 6:
			grd = "양";
			break;
		default:
			grd = "가";
		}
		return grd;
	}

}// class 닫음
